﻿using System;
using System.IO;
using System.Runtime.InteropServices;
using UtilZ.Dotnet.Ex.Base;

namespace UtilZ.Dotnet.AudioPlayer.Native
{
    internal class BASS_MIXNativeMethods
    {
        //internal const string BASS_MIX_DLL = @"bassmix.dll";
        internal const string BASS_MIX_DLL = @"bassmix";

        private static string _dllDir;
        public static string DllDir
        {
            get { return _dllDir; }
        }

        static BASS_MIXNativeMethods()
        {
            string assemblyDir = PathEx.GetTypeAssemblyDirectory(typeof(BASSNativeMethods));
            if (Environment.Is64BitProcess)
            {
                _dllDir = Path.Combine(assemblyDir, "x64");
            }
            else
            {
                _dllDir = Path.Combine(assemblyDir, "x86");
            }

            //加载bassmix.dll
            string dllPath = Path.Combine(_dllDir, BASS_MIX_DLL);
            OSSystemApis.LoadEx(dllPath);
        }


        [return: MarshalAs(UnmanagedType.Bool)]
        [DllImport(BASS_MIX_DLL)]
        internal static extern bool BASS_Mixer_StreamAddChannel(int handle, int channel, BASSFlag flags);

        [return: MarshalAs(UnmanagedType.Bool)]
        [DllImport(BASS_MIX_DLL)]
        internal static extern bool BASS_Mixer_StreamAddChannelEx(int handle, int channel, BASSFlag flags, long start, long length);

        [DllImport(BASS_MIX_DLL)]
        internal static extern int BASS_Mixer_StreamCreate(int freq, int chans, BASSFlag flags);

    }
}
